package com.qili.controller.sys;

import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;

/**
 * @author zhuxiaomeng
 * @date 2017/12/19.
 * @email 154040976@qq.com
 * 404 403 500
 */
@Controller
@RequestMapping(value = "/error")
public class ErrorController {

    @GetMapping(value = "404")
    public String pageNotFound() {
        return "error/404";
    }

    @GetMapping(value = "403")
    public String notFound(String message, Model model) {
        if (!StringUtils.isEmpty(message)) {
            model.addAttribute("message", message);
        }
        return "error/403";
    }
    @GetMapping(value = "upgrading")
    public String upgrading(String message, Model model) {
        model.addAttribute("status", "^-^ 温馨提示：");
        model.addAttribute("message", "此功能正在开发中，敬请期待.....");
        return "error/error";
    }

    /**
     * 没有页面权限提示页
     * @param model
     * @return
     */
    @GetMapping(value = "/noMenuPer")
    public String noMenuPer(HttpServletRequest request, Model model) {
        model.addAttribute("status", "^-^ 温馨提示：");
        model.addAttribute("message", request.getAttribute("msg") == null ? "没有菜单权限 " : request.getAttribute("msg").toString());
        return "error/noMenuPer";
    }

}
